\(\int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx\) [306]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F(-1)]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 15, antiderivative size = 39 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=-\frac {x}{b}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} b} \]

[Out]

-x/b+arctan((a+b)^(1/2)*tan(x)/a^(1/2))*(a+b)^(1/2)/b/a^(1/2)

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.267, Rules used = {3270, 400, 209, 211} \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} b}-\frac {x}{b} \]

[In]

Int[Cos[x]^2/(a + b*Sin[x]^2),x]

[Out]

-(x/b) + (Sqrt[a + b]*ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]])/(Sqrt[a]*b)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 400

Int[1/(((a_) + (b_.)*(x_)^(n_))*((c_) + (d_.)*(x_)^(n_))), x_Symbol] :> Dist[b/(b*c - a*d), Int[1/(a + b*x^n),
 x], x] - Dist[d/(b*c - a*d), Int[1/(c + d*x^n), x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0]

Rule 3270

Int[cos[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.), x_Symbol] :> With[{ff = FreeF
actors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(a + (a + b)*ff^2*x^2)^p/(1 + ff^2*x^2)^(m/2 + p + 1), x], x, T
an[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[m/2] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = \text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \left (a+(a+b) x^2\right )} \, dx,x,\tan (x)\right ) \\ & = -\frac {\text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (x)\right )}{b}+\frac {(a+b) \text {Subst}\left (\int \frac {1}{a+(a+b) x^2} \, dx,x,\tan (x)\right )}{b} \\ & = -\frac {x}{b}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} b} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.09 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.00 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=-\frac {x}{b}+\frac {\sqrt {a+b} \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{\sqrt {a} b} \]

[In]

Integrate[Cos[x]^2/(a + b*Sin[x]^2),x]

[Out]

-(x/b) + (Sqrt[a + b]*ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]])/(Sqrt[a]*b)

Maple [A] (verified)

Time = 0.35 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.97

method result size
default \(-\frac {\arctan \left (\tan \left (x \right )\right )}{b}+\frac {\left (a +b \right ) \arctan \left (\frac {\left (a +b \right ) \tan \left (x \right )}{\sqrt {a \left (a +b \right )}}\right )}{b \sqrt {a \left (a +b \right )}}\) \(38\)
risch \(-\frac {x}{b}+\frac {\sqrt {-a \left (a +b \right )}\, \ln \left ({\mathrm e}^{2 i x}+\frac {2 i \sqrt {-a \left (a +b \right )}-2 a -b}{b}\right )}{2 a b}-\frac {\sqrt {-a \left (a +b \right )}\, \ln \left ({\mathrm e}^{2 i x}-\frac {2 i \sqrt {-a \left (a +b \right )}+2 a +b}{b}\right )}{2 a b}\) \(97\)

[In]

int(cos(x)^2/(a+b*sin(x)^2),x,method=_RETURNVERBOSE)

[Out]

-1/b*arctan(tan(x))+(a+b)/b/(a*(a+b))^(1/2)*arctan((a+b)*tan(x)/(a*(a+b))^(1/2))

Fricas [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 206, normalized size of antiderivative = 5.28 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=\left [\frac {\sqrt {-\frac {a + b}{a}} \log \left (\frac {{\left (8 \, a^{2} + 8 \, a b + b^{2}\right )} \cos \left (x\right )^{4} - 2 \, {\left (4 \, a^{2} + 5 \, a b + b^{2}\right )} \cos \left (x\right )^{2} - 4 \, {\left ({\left (2 \, a^{2} + a b\right )} \cos \left (x\right )^{3} - {\left (a^{2} + a b\right )} \cos \left (x\right )\right )} \sqrt {-\frac {a + b}{a}} \sin \left (x\right ) + a^{2} + 2 \, a b + b^{2}}{b^{2} \cos \left (x\right )^{4} - 2 \, {\left (a b + b^{2}\right )} \cos \left (x\right )^{2} + a^{2} + 2 \, a b + b^{2}}\right ) - 4 \, x}{4 \, b}, -\frac {\sqrt {\frac {a + b}{a}} \arctan \left (\frac {{\left ({\left (2 \, a + b\right )} \cos \left (x\right )^{2} - a - b\right )} \sqrt {\frac {a + b}{a}}}{2 \, {\left (a + b\right )} \cos \left (x\right ) \sin \left (x\right )}\right ) + 2 \, x}{2 \, b}\right ] \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2),x, algorithm="fricas")

[Out]

[1/4*(sqrt(-(a + b)/a)*log(((8*a^2 + 8*a*b + b^2)*cos(x)^4 - 2*(4*a^2 + 5*a*b + b^2)*cos(x)^2 - 4*((2*a^2 + a*
b)*cos(x)^3 - (a^2 + a*b)*cos(x))*sqrt(-(a + b)/a)*sin(x) + a^2 + 2*a*b + b^2)/(b^2*cos(x)^4 - 2*(a*b + b^2)*c
os(x)^2 + a^2 + 2*a*b + b^2)) - 4*x)/b, -1/2*(sqrt((a + b)/a)*arctan(1/2*((2*a + b)*cos(x)^2 - a - b)*sqrt((a
+ b)/a)/((a + b)*cos(x)*sin(x))) + 2*x)/b]

Sympy [F(-1)]

Timed out. \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=\text {Timed out} \]

[In]

integrate(cos(x)**2/(a+b*sin(x)**2),x)

[Out]

Timed out

Maxima [A] (verification not implemented)

none

Time = 0.36 (sec) , antiderivative size = 35, normalized size of antiderivative = 0.90 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=\frac {{\left (a + b\right )} \arctan \left (\frac {{\left (a + b\right )} \tan \left (x\right )}{\sqrt {{\left (a + b\right )} a}}\right )}{\sqrt {{\left (a + b\right )} a} b} - \frac {x}{b} \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2),x, algorithm="maxima")

[Out]

(a + b)*arctan((a + b)*tan(x)/sqrt((a + b)*a))/(sqrt((a + b)*a)*b) - x/b

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.59 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=\frac {{\left (\pi \left \lfloor \frac {x}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (2 \, a + 2 \, b\right ) + \arctan \left (\frac {a \tan \left (x\right ) + b \tan \left (x\right )}{\sqrt {a^{2} + a b}}\right )\right )} {\left (a + b\right )}}{\sqrt {a^{2} + a b} b} - \frac {x}{b} \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2),x, algorithm="giac")

[Out]

(pi*floor(x/pi + 1/2)*sgn(2*a + 2*b) + arctan((a*tan(x) + b*tan(x))/sqrt(a^2 + a*b)))*(a + b)/(sqrt(a^2 + a*b)
*b) - x/b

Mupad [B] (verification not implemented)

Time = 14.02 (sec) , antiderivative size = 272, normalized size of antiderivative = 6.97 \[ \int \frac {\cos ^2(x)}{a+b \sin ^2(x)} \, dx=-\frac {\mathrm {atan}\left (\frac {2\,a^2\,\mathrm {tan}\left (x\right )}{2\,a^2+4\,a\,b+2\,b^2}+\frac {2\,b^2\,\mathrm {tan}\left (x\right )}{2\,a^2+4\,a\,b+2\,b^2}+\frac {4\,a\,b\,\mathrm {tan}\left (x\right )}{2\,a^2+4\,a\,b+2\,b^2}\right )}{b}-\frac {\mathrm {atanh}\left (\frac {6\,b^2\,\mathrm {tan}\left (x\right )\,\sqrt {-a^2-b\,a}}{2\,a^3+6\,a^2\,b+6\,a\,b^2+2\,b^3}+\frac {2\,a\,\mathrm {tan}\left (x\right )\,\sqrt {-a^2-b\,a}}{6\,a\,b+2\,a^2+6\,b^2+\frac {2\,b^3}{a}}+\frac {6\,b\,\mathrm {tan}\left (x\right )\,\sqrt {-a^2-b\,a}}{6\,a\,b+2\,a^2+6\,b^2+\frac {2\,b^3}{a}}+\frac {2\,b^3\,\mathrm {tan}\left (x\right )\,\sqrt {-a^2-b\,a}}{2\,a^4+6\,a^3\,b+6\,a^2\,b^2+2\,a\,b^3}\right )\,\sqrt {-a\,\left (a+b\right )}}{a\,b} \]

[In]

int(cos(x)^2/(a + b*sin(x)^2),x)

[Out]

- atan((2*a^2*tan(x))/(4*a*b + 2*a^2 + 2*b^2) + (2*b^2*tan(x))/(4*a*b + 2*a^2 + 2*b^2) + (4*a*b*tan(x))/(4*a*b
 + 2*a^2 + 2*b^2))/b - (atanh((6*b^2*tan(x)*(- a*b - a^2)^(1/2))/(6*a*b^2 + 6*a^2*b + 2*a^3 + 2*b^3) + (2*a*ta
n(x)*(- a*b - a^2)^(1/2))/(6*a*b + 2*a^2 + 6*b^2 + (2*b^3)/a) + (6*b*tan(x)*(- a*b - a^2)^(1/2))/(6*a*b + 2*a^
2 + 6*b^2 + (2*b^3)/a) + (2*b^3*tan(x)*(- a*b - a^2)^(1/2))/(2*a*b^3 + 6*a^3*b + 2*a^4 + 6*a^2*b^2))*(-a*(a +
b))^(1/2))/(a*b)